package com.linhai.scm.struts2;

import org.springframework.beans.factory.annotation.Autowired;

import com.linhai.scm.service.IUserService;
import com.opensymphony.xwork2.ActionSupport;

public class DemoAction extends ActionSupport {
	
	private static final long serialVersionUID = 1L;
	
	@Autowired
	private IUserService service;
    
	private String msg;
	public void setMsg(String msg){
		this.msg=msg;
	}
	public String getMsg(){
		return msg;
	}
	
    private String name;
    private String pwd;
    
    public String execute() {
    	
    	System.out.println("teetsetsdfdsf==========--");
        return SUCCESS;
    }
    
    public String login() {
        return SUCCESS;
    }
    
    public String auth() {
    	com.linhai.scm.entity.base.User user=new com.linhai.scm.entity.base.User();
    	user.setUserName(name);
    	user.setUserPwd(pwd);
    	if(service.auth(user)){
    		return SUCCESS;
    	}else{
    		setMsg("输入的用户名或密码不正确!!!!!");
            return ERROR;
    	}
    	// 只有用户名为linhai，密码为123456方可成功登陆
//        if (name.equals("linhai") && pwd.equals("123")) {
//            return SUCCESS;
//        } else {
//        	setMsg("用户名或密码不正确");
//            return ERROR;
//        }
    }
    
    public String user() {
        return SUCCESS;
    }
    
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }
    
}